"""
#!/usr/bin/python3
# -*- coding: utf-8 -*-
@CTime      : 2018/10/28 14:06
@Email      : ysling129.com
@File       : MysqlDispost.py
@Software   : PyCharm
@Description:
"""
__author__ = 'ling'

import mysql.connector
from mysql.connector import errorcode


class MysqlDispost:

    def __init__(self, user='root', password='root', host='127.0.0.1', port=3306, database='mysql'):
        self.user = user
        self.password = password
        self.host = host
        self.port = port
        self.database = database
        try:
            self.mysql = mysql.connector.connect(user=self.user, password=self.password, port=self.port, database=self.database)
            print("----------------------------------------\n--\t进入数据库\n----------------------------------------\n")
        except mysql.connector.Error as err:
            if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
                print("您输入的名字或密码错误")
            elif err.errno == errorcode.ER_BAD_DB_ERROR:
                print("数据库不存在")
            else:
                print(err)




if __name__ == '__main__':
    a = MysqlDispost(port=3306)


